/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package server.entities;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.omg.IOP.Codec;
import server.tools.MD5Hash;

/**
 *
 * @author efim
 */
@Entity 
@XmlRootElement
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id      
    @GeneratedValue(strategy = GenerationType.TABLE)
    private Long id;

    public Long getId() {
        return id;
    }
    @XmlElement
    public void setId(Long id) {
        this.id = id;
    }
    
    
    private String fname;

    /**
     * Get the value of fname
     *
     * @return the value of fname
     */
    public String getFname() {
        return fname;
    }

    /**
     * Set the value of fname
     *
     * @param fname new value of fname
     */
    @XmlElement
    public void setFname(String fname) {
        this.fname = fname;
    }
    
   
    private String lname;

    /**
     * Get the value of lname
     *
     * @return the value of lname
     */
    public String getLname() {
        return lname;
    }

    /**
     * Set the value of lname
     *
     * @param lname new value of lname
     */
    @XmlElement
    public void setLname(String lname) {
        this.lname = lname;
    }
    
    
    private String email;

    /**
     * Get the value of email
     *
     * @return the value of email
     */
    public String getEmail() {
        return email;
    }

    /**
     * Set the value of email
     *
     * @param email new value of email
     */
    @XmlElement
    public void setEmail(String email) {
        this.email = email;
    }
    
    private String password;

    
    /**
     * Set the value of password
     *
     * @param password new value of password
     */    
    public void setPassword(String password) {       
        this.password = password;
    }
    
    private String accessToken;  

    /**
     * Set the value of accessToken
     *
     * @param accessToken new value of accessToken
     */
    
    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof User)) {
            return false;
        }
        User other = (User) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        if((this.email != other.email)||(this.password!=other.password))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.User[ id=" + id + " ]";
    }
    
    
    
}
